
\documentclass[a4paper]{article}

% SEE ALSO : unittest_colormap_input.tex

\usepackage{pgfplots}
\usepackage{pgfplots.assert}
    \pgfplotsset{compat=1.13}

\begin{document}

%\tracingcommands=2\tracingmacros=2
%

\makeatletter

\pgfplotsset{
	colormap={initial}{rgb=(0,0,0) rgb=(1,0,0)},
}

{
\pgfplotsset{
	colormap={actual}{
		color=(red)
		color of colormap(10pt)=(250 of initial)
		color of colormap(30pt)=(750 of initial)
	},
}
\pgfplotscolormapserializetomacro{actual}\ofcolormapwithpositions
\def\expected{%
	\expandafter \def \csname pgfpl@cm@actual@h\endcsname {333.32993}%
	\expandafter \def \csname pgfpl@cm@actual@invh\endcsname {0.003}%
	\def \pgfplots@loc@TMPa {{1.0,0.0,0.0},{0.25177,0.0,0.0},{0.50354,0.0,0.0},{0.75531,0.0,0.0}}%
	\pgfplotsarraynewempty {pgfpl@cm@actual}%
	\expandafter \pgfplotsutilforeachcommasep \pgfplots@loc@TMPa \as \pgfplots@loc@TMPb {%
		\ifx \pgfplots@loc@TMPb \pgfutil@empty \else
			\expandafter \pgfplotsarraypushback \pgfplots@loc@TMPb \to {pgfpl@cm@actual}%
		\fi
	}%
	\def \pgfpl@cm@actual@colspace {rgb}%
	\def \pgfpl@cm@actual@col@comps {3}%
	\def \pgfpl@cm@actual@lastindex {3}%
	\def \pgfplots@loc@TMPa {}%
	\pgfplotsarraynewempty {pgfpl@cm@actual@X}%
	\expandafter \pgfplotsutilforeachcommasep \pgfplots@loc@TMPa \as \pgfplots@loc@TMPb {%
		\ifx \pgfplots@loc@TMPb \pgfutil@empty \else
			\expandafter \pgfplotsarraypushback \pgfplots@loc@TMPb \to {pgfpl@cm@actual@X}%
		\fi
	}%
	\def \pgfpl@cm@actual@X@scale@order@z {0}%
}%
\pgfplotsassertequalstoknoexpand{\expected}{\ofcolormapwithpositions}{unexpected actual}
}

\begingroup
	\pgfplotscreatecolormap{my map}{rgb255(0cm)=(0,0,128) rgb255(1cm)=(0,0,255) rgb255(3cm)=(0,255,255) rgb255(5cm)=(255,255,0) rgb255(7cm)=(255,0,0) rgb255(8cm)=(128,0,0)}
	\pgfplotscolormapserializecomponentstomacro{my map}\actual

	\pgfplotsassertequalstok{%
		{0.0,0.0,0.50195},% 0cm
		{0.0,0.0,0.99998},% 1cm
		{0.0,0.49998,0.99997},% interpoalted 2cm
		{0.0,0.99998,0.99998},% 3cm
		{0.49998,0.99997,0.49998},% interpolated 4cm
		{0.99998,0.99998,0.0},% 5cm
		{0.99997,0.49998,0.0},% interpoalted 6cm
		{0.99998,0.0,0.0},% 7cm
		{0.50195,0.0,0.0}% 8cm
	}{\actual}{}

	\csname pgfplots@colormap@showdebuginfofor\endcsname{my map}

	\pgfplotscolormapgetmeshwidth{my map}%
	\pgfplotsassertequalstok{125.00143}{\pgfplotsretval}{}

	\pgfplotscolormapgetcolorspace{my map}
	\pgfplotsassertequalstok{rgb}{\pgfplotsretval}{}

	\pgfplotscolormapifisuniform{my map}{}{\pgfplotsassertfail{should be uniform}}
\endgroup
\end{document}
